<?php

namespace app\common\model;

use think\Model;

class Users extends Model
{
    //
    protected $pk='uid';

    protected $autoWriteTimestamp=true;
    
    /*public function getStatusAttr($value){       获取器
        $status=[-1=>'删除',0=>'禁用',1=>'正常',2=>'待审核'];
        return $status[$value];
    }*/

    //关联关注表
    public function follows(){
        return $this->hasMany('Follows','user_id','uid');
    }

    //关联粉丝表
    public function fans(){
        return $this->hasMany('Fans','user_id','uid');
    }

    //是否当前用户关注了此用户
    public function hasFollow(){
        return $this->hasMany('Fans','user_id','uid')->where('fan_id',session('uid'))->where('status',1);
    }
}
